# Contributor: Sean McAvoy <seanmcavoy@gmail.com>
# Maintainer: Sean McAvoy <seanmcavoy@gmail.com>
pkgname=barrier
pkgver=2.4.0
pkgrel=1
pkgdesc="share keyboard and mouse between systems over network"
url="https://github.com/debauchee/barrier"
arch="all"
license="GPL-2.0-only"
depends="hicolor-icon-theme"
makedepends="qt5-qtbase-dev cmake avahi-dev libxtst-dev curl-dev gtest-dev samurai"
subpackages="$pkgname-doc"
_filesystemver=614bbe87b80435d87ab8791564370e0c1d13627d
source="$pkgname-$pkgver.tar.gz::https://github.com/debauchee/barrier/archive/v$pkgver.tar.gz
	https://github.com/gulrak/filesystem/archive/$_filesystemver/filesystem-$_filesystemver.tar.gz

	0001-cstddef.patch
	"

prepare() {
	rmdir ext/gulrak-filesystem
	mv "$srcdir"/filesystem-$_filesystemver ext/gulrak-filesystem

	default_prepare
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBARRIER_REVISION:STRING=00000000 \
		-DBARRIER_VERSION_STAGE=RELEASE \
		-DBARRIER_USE_EXTERNAL_GTEST=true
	cmake --build build
}

check() {
	PATH="$PATH:$PWD/build/bin" \
	ctest --output-on-failure --test-dir build
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install

	# license
	install -Dm0644 LICENSE -t "$pkgdir"/usr/share/doc/"$pkgname"

	# manpages
	install -Dm0644 doc/*.1 -t "$pkgdir"/usr/share/man/man1

	# examples
	install -Dm0644 doc/barrier.conf.example* -t "$pkgdir"/usr/share/doc/"$pkgname"
}

sha512sums="
dff8d95c358688952baee0bbbf56b818e40a6c0483d58f6cadd55558ab5d0cefc92a37b0751bfd70868686e1716c729871ae00a30ee9b0ba944f531dfb742449  barrier-2.4.0.tar.gz
6190a994ce7296a7e0c29d1e079de9dbf5a16667f6339b52b4b2c537ba569f53fc12ee1c361ec1f38474c263a0b7aa995a95d41da9bf6cedc78c6231ce586b70  filesystem-614bbe87b80435d87ab8791564370e0c1d13627d.tar.gz
113ec97e6b2076f46b9b03eabb84a63ad60f3c612a5bc1e8c1d80d8db54817805ffa9e3436dba87471963d329a27419ef94e192cd7f4809882587044a6704a8d  0001-cstddef.patch
"
